package io.wins.vertx.verticle;

import io.vertx.core.DeploymentOptions;
import io.vertx.core.Future;
import io.wins.vertx.service.CommentService;
import io.wins.vertx.verticle.api.CommentApiVerticle;

public class CommentVerticle extends BaseVerticle {
    @Override
    public void start(final Future<Void> future) throws Exception {
        super.start();
        final CommentService commentService = CommentService.create(this.vertx);
        this.deployRestService(commentService).setHandler(future.completer());
    }

    private Future<Void> deployRestService(final CommentService service) {
        final Future<String> future = Future.future();
        this.vertx.deployVerticle(new CommentApiVerticle(service),
            new DeploymentOptions().setConfig(this.config()),
            future.completer());
        return future.map(v -> null);
    }
}
